﻿Public Class PMTTablesParam
    Implements IPMTTablesParam

    Private _TableCorrespCRT_PMT As IFichierPMT
    Private _TableCorrespGenTarif_GenCompta As IFichierPMT
    Private _TableNveauxGpes As IFichierPMT
    Private _TableNvellesGen As IFichierPMT
    Private _TablePerimetres As IFichierPMT

    Public Sub New()
        _TableCorrespCRT_PMT = New FichierPMT_NonRenseigne
        _TableCorrespGenTarif_GenCompta = New FichierPMT_NonRenseigne
        _TableNveauxGpes = New FichierPMT_NonRenseigne
        _TableNvellesGen = New FichierPMT_NonRenseigne
        _TablePerimetres = New FichierPMT_NonRenseigne
    End Sub

    Public Property CorrespCRT_PMT As IFichierPMT Implements IPMTTablesParam.CorrespCRT_PMT
        Get
            Return _TableCorrespCRT_PMT
        End Get
        Set(value As IFichierPMT)
            _TableCorrespCRT_PMT = value
            RaiseEvent CorrespCRT_PMT_Changed(Me, New EventArgs)
        End Set
    End Property
    Public Property CorrespGenTarif_GenCompta As IFichierPMT Implements IPMTTablesParam.CorrespGenTarif_GenCompta
        Get
            Return _TableCorrespGenTarif_GenCompta
        End Get
        Set(value As IFichierPMT)
            _TableCorrespGenTarif_GenCompta = value
            RaiseEvent CorrespGenTarif_GenCompta_Changed(Me, New EventArgs)
        End Set
    End Property
    Public Property NveauxGpes As IFichierPMT Implements IPMTTablesParam.NveauxGpes
        Get
            Return _TableNveauxGpes
        End Get
        Set(value As IFichierPMT)
            _TableNveauxGpes = value
            RaiseEvent NveauxGpes_Changed(Me, New EventArgs)
        End Set
    End Property
    Public Property NvellesGen As IFichierPMT Implements IPMTTablesParam.NvellesGen
        Get
            Return _TableNvellesGen
        End Get
        Set(value As IFichierPMT)
            _TableNvellesGen = value
            RaiseEvent NvellesGen_Changed(Me, New EventArgs)
        End Set
    End Property
    Public Property Perimetres As IFichierPMT Implements IPMTTablesParam.Perimetres
        Get
            Return _TablePerimetres
        End Get
        Set(value As IFichierPMT)
            _TablePerimetres = value
            RaiseEvent Perimetres_Changed(Me, New EventArgs)
        End Set
    End Property

    Public Event CorrespCRT_PMT_Changed(sender As Object, e As EventArgs) Implements IPMTTablesParam.CorrespCRT_PMT_Changed
    Public Event CorrespGenTarif_GenCompta_Changed(sender As Object, e As EventArgs) Implements IPMTTablesParam.CorrespGenTarif_GenCompta_Changed
    Public Event NveauxGpes_Changed(sender As Object, e As EventArgs) Implements IPMTTablesParam.NveauxGpes_Changed
    Public Event NvellesGen_Changed(sender As Object, e As EventArgs) Implements IPMTTablesParam.NvellesGen_Changed
    Public Event Perimetres_Changed(sender As Object, e As EventArgs) Implements IPMTTablesParam.Perimetres_Changed

    Public Function GetSchema() As Xml.Schema.XmlSchema Implements Xml.Serialization.IXmlSerializable.GetSchema
        Return Nothing
    End Function

    Public Sub ReadXml(reader As Xml.XmlReader) Implements Xml.Serialization.IXmlSerializable.ReadXml
        Dim XmlTblesParam As XElement = XElement.Load(reader)
        _TableCorrespCRT_PMT = FichierPMT_Builer.ReadXml(XmlTblesParam.<PMTTablesParam>.<CorrespCRT_PMT>.FirstOrDefault.CreateReader)
        _TableCorrespGenTarif_GenCompta = FichierPMT_Builer.ReadXml(XmlTblesParam.<PMTTablesParam>.<CorrespGenTarif_GenCompta>.FirstOrDefault.CreateReader)
        _TableNveauxGpes = FichierPMT_Builer.ReadXml(XmlTblesParam.<PMTTablesParam>.<NveauxGpes>.FirstOrDefault.CreateReader)
        _TableNvellesGen = FichierPMT_Builer.ReadXml(XmlTblesParam.<PMTTablesParam>.<NvellesGen>.FirstOrDefault.CreateReader)
        _TablePerimetres = FichierPMT_Builer.ReadXml(XmlTblesParam.<PMTTablesParam>.<Perimetres>.FirstOrDefault.CreateReader)
    End Sub

    Public Sub WriteXml(writer As Xml.XmlWriter) Implements Xml.Serialization.IXmlSerializable.WriteXml
        writer.WriteStartElement("PMTTablesParam")

        writer.WriteStartElement("CorrespCRT_PMT")
        CorrespCRT_PMT.WriteXml(writer)
        writer.WriteEndElement()

        writer.WriteStartElement("CorrespGenTarif_GenCompta")
        CorrespGenTarif_GenCompta.WriteXml(writer)
        writer.WriteEndElement()

        writer.WriteStartElement("NveauxGpes")
        NveauxGpes.WriteXml(writer)
        writer.WriteEndElement()

        writer.WriteStartElement("NvellesGen")
        NvellesGen.WriteXml(writer)
        writer.WriteEndElement()

        writer.WriteStartElement("Perimetres")
        Perimetres.WriteXml(writer)
        writer.WriteEndElement()

        writer.WriteEndElement()
    End Sub
End Class
